<template>
  <div :class="showHoverCom ? 'com-hover' : ''">
    <div class="page-header" :style="moduleCss">
      <div :style="moduleBgCss" class="module-bg"></div>
      <div class="header-content">
        <div class="header-title" v-show="propsData.params.showText == 1 && styleType == 1" :style="textFontCss">
          {{ propsData.params.text }}
        </div>
        <!-- 门店组件 -->
        <div class="md-section" v-if="isIndexPage && styleType == 2">
          <i
            class="iconfont icon-map-filling1"
            :style="{
              color: mdFontCss.color
            }"
          ></i>
          <div class="md-name" :style="mdFontCss">洛阳理工学院(王城校区)</div>
          <i
            class="iconfont icon-weibiaoti-13"
            :style="{
              color: mdFontCss.color
            }"
          ></i>
        </div>
        <img class="capsule-img" src="@/assets/images/diy/capsule.png" alt="" />
      </div>
    </div>
    <div class="holo-place"></div>
  </div>
</template>

<script>
import { mixinsModuleCss } from '@/components/DiyNew/diy/mixins/index.js'

export default {
  name: 'pageHeader',
  props: {
    propsData: {
      type: Object,
      default: {}
    }
  },
  mixins: [mixinsModuleCss],
  data() {
    return {}
  },
  mounted() {
    console.log('组件挂载了：', this.propsData)
  },
  watch: {},
  computed: {
    showHoverCom() {
      let flag = false
      if (this.$diyObser.store.currentComponent?.comName) {
        if (this.$diyObser.store.currentComponent.comName == 'pageHeader') {
          flag = true
        }
      }
      return flag
    },
    styleType() {
      return this.propsData.params.styleType
    },
    mdStyle() {
      return this.propsData.params.mdStyle
    },
    capsuleType() {
      return this.propsData.params.capsuleType
    },
    isIndexPage() {
      let page = this.$diyObser.store.currentPage
      return page.is_index == 1
    },
    mdFontCss() {
      let style = Object.assign({}, this.propsData.params.css)
      delete style.textAlign
      if (style.fontNum) {
        style.fontSize = style.fontNum + 'px'
      }
      return style
    },
    textFontCss() {
      let style = Object.assign({}, this.propsData.params.css)
      if (style.fontNum) {
        style.fontSize = style.fontNum + 'px'
      }
      return style
    }
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
.page-header {
  width: 376px;
  height: 44px;
  background-color: #fa2c1b;
  padding-top: 7px;
  position: fixed;
  top: -1px;
  left: 0;
  z-index: 511;
  margin: 0 !important;
  border-radius: 0 !important;
  .module-bg {
    width: 100%;
    height: 100%;
    z-index: -1;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 0 !important;
  }
  .header-content {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    position: relative;
    .capsule-img {
      width: 87px;
      height: 32px;
      position: absolute;
      right: 7px;
      top: 0;
      z-index: 12;
    }
    .header-title {
      width: 92%;
      font-size: 18px;
      font-weight: 600;
      color: #ffffff;
      text-align: center;
      position: absolute;
      left: 4%;
      top: 0;
      z-index: 11;
      height: 32px;
      line-height: 32px;
    }
    .md-section {
      width: calc(100% - 108px);
      height: 32px;
      position: absolute;
      left: 7px;
      top: 0;
      z-index: 11;
      display: flex;
      align-items: center;
      .md-media {
        width: 24px;
        height: 24px;
        background: #f2f2f2;
        border: 1px solid #ffffff;
        border-radius: 50%;
        margin-right: 6px;
      }
      .md-name {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 600;
        color: #ffffff;
      }
      .icon-weibiaoti-13 {
        font-size: 12px;
        transform: scale(0.7);
        font-weight: bolder;
        position: relative;
        margin-left: 2px;
        top: 1.2px;
        color: #ffffff;
      }

      .icon-map-filling1 {
        font-size: 18px;
        position: relative;
        color: #ffffff;
      }
    }
    .black-md {
      .iconfont,
      .md-name {
        color: #000000;
      }
    }
  }
}
.holo-place {
  width: 100%;
  height: 42px;
}
.com-hover::before {
  content: '';
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  border: 1px dashed;
  border-color: #000000;
  z-index: 512;
  display: inline-block;
  pointer-events: none;
}
</style>
